import 'package:aone_common/common.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:prototype/theme/custom_theme.dart';

class GameInitView extends StatelessWidget {
  const GameInitView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final siteItems = GlobalService.to.state.siteItems;
    final logic = Get.put(GameInitLogic());
    final state = Get.find<GameInitLogic>().state;
    return Container(
      decoration: const BoxDecoration(
        image: DecorationImage(
          fit: BoxFit.fill,
          image: AssetImage('assets/images/game_init/loadingBg.png'),
        ),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          CachedNetworkImage(
            imageUrl: siteItems.logoSquare!,
            width: 150.w,
          ),
          SizedBox(
            height: 100.h,
          ),
          Image.asset('assets/images/game_init/loadingSlogan.png'),
          SizedBox(
            height: 100.h,
          ),
          SizedBox(
            width: 330.w,
            child: Column(
              children: [
                LinearPercentIndicator(
                  barRadius: const Radius.circular(20),
                  progressColor: CustomTheme.colorSchema.primaryColor,
                  backgroundColor: CustomTheme.colorSchema.secondary,
                  percent: state.progress,
                  lineHeight: 8.h,
                  animationDuration: 500,
                  animation: true,
                ),
                Text(
                  'loading'.tr + '...',
                  textHeightBehavior: const TextHeightBehavior(
                    leadingDistribution: TextLeadingDistribution.proportional,
                  ),
                  style: TextStyle(
                    color: CustomTheme.colorSchema.neutral,
                    height: 2,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
